package com.neu.his.registlevel.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neu.his.commonutils.R;
import com.neu.his.registlevel.entity.RegistLevel;
import com.neu.his.registlevel.service.RegistLevelService;

@CrossOrigin
@RestController
@RequestMapping("/his/registlevel")
public class RegistLevelController {
		@Autowired
		private RegistLevelService registLevelService;
//		添加挂号级别
		@PostMapping("/addRegistLevel")
		public R addRegistLevel(@RequestBody RegistLevel registLevel) {
			System.out.println(registLevel);
			boolean save=registLevelService.addRegistLevel(registLevel);
			return R.ok().data("save",save);
		}
//		删除挂号级别通过id
		@PostMapping("/delRegistLevel")
		public R delRegistLevel(int id) {
			boolean flag= registLevelService.delRegistLevel(id);
			return R.ok().data("flag",flag);
		}
//		修改挂号级别
		@PostMapping("/updateRegistLevel")
		public R updateRegistLevel(@RequestBody RegistLevel registLevel) {
			System.out.println(registLevel);
			boolean upd= registLevelService.updateRegistLevel(registLevel);
			return R.ok().data("upd",upd);	
		}
//		分页查询挂号级别
		@GetMapping("/pageRegistLevel")
		public R pageRegistLevel(int page,int limit) {
			System.out.println(page);
			System.out.println(limit);
			page=(page-1)*limit;
			List<RegistLevel> list=registLevelService.pageRegistLevel(page,limit);
			return R.ok().data("list",list);
		}
}
